<?php 
/**
 * Utilidades de Fecha/Hora
 * 
 */

class Zwei_Utils_Time{
	
	public function secondsToHMS ($sec, $padHours = false, $showSeconds = true, $showDays=false, $addSufix=false) 
	{
		$suDays=($addSufix)?"<span>D&iacute;as</span>":"";
		$suHours=($addSufix)?"<span>Horas</span>":"";
		$suMins=($addSufix)?"<span>Minutos</span>":"";
		$suSecs=($addSufix)?"<span>Segundos</span>":"";
		
	    $hms = "";
		
		if($showDays){
			$days = intval($sec / 86400);
			$hours = intval($sec / 3600) % (24);
			$hms.= str_pad($days, 2, "0", STR_PAD_LEFT).$suDays.":";
			
		}else{
			$hours = intval($sec / 3600);
		}

		
     	$hms .= ($padHours) 
          ? str_pad($hours, 2, "0", STR_PAD_LEFT).$suHours. ":"
          : $hours.$suHours. ":";
    
	    $minutes = intval(($sec / 60) % 60); 

	    $hms .= str_pad($minutes, 2, "0", STR_PAD_LEFT).$suMins;

	    if($showSeconds){
	    	$hms .= ":";
	    	$seconds = intval($sec % 60).$suSecs; 
	    	$hms .= str_pad($seconds, 2, "0", STR_PAD_LEFT);
	    }
	    return $hms;
	}
}
?>